if(getQueryString("providerId")){
    var providerId = getQueryString("providerId");
}
if(getQueryString("id")){
    var id = getQueryString("id");//服务商数据主键
    getProviderInvoiceByProviderIdFn();
}
/*获取发票信息详情*/
function getProviderInvoiceByProviderIdFn() {
    web.doAjax(root.approvedServiceProviders.getProviderInvoiceByProviderIdAndId, 'post', {providerId: providerId,id:id}, function (data) {
        if(data.code == 0){
            var result = data.data;
            $(".address").val(result.address);
            $(".bankAccount").val(result.bankAccount);
            $(".bankAccountNumber").val(result.bankAccountNumber);
            $(".companyName").val(result.companyName);
            $(".phone").val(result.phone);
            $(".taxNo").val(result.taxNo);
        }else {
            $.Huimodalalert(data.msg,2000);
        }
    },2);
}
$(".billing-form").Validform({
    tiptype: 2,
    callback: function (form) {
        confirmBtn();
        return false;
    }
});
/*保存发票信息*/
function confirmBtn() {
    var params = {
        "address": $(".address").val(),
        "bankAccount": $(".bankAccount").val(),
        "bankAccountNumber": $(".bankAccountNumber").val(),
        "companyName": $(".companyName").val(),
        "createUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
        "phone": $(".phone").val(),
        "providerId": providerId,
        "taxNo": $(".taxNo").val(),
        "updateUserName": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name
    }
    if(id){
        params.id = id;
        var doUrl = root.approvedServiceProviders.updateProviderInvoiceById;
    }else {
        var doUrl = root.approvedServiceProviders.addProviderInvoice;
    }
    console.log(params)
    web.doAjax(doUrl, 'post', params, function (data) {
        console.log(data)
        if(data.code == 0){
            $.Huimodalalert("操作成功",2000);
            parent.findProviderInvoiceByPageFn(1);
            setTimeout(() => {
                cancelLayerNoRefreshFn();
            },200);
        }else {
            $.Huimodalalert(data.msg,2000);
        }
    },1);
}
